package ar.com.ctrln.persistence.model.proveedor;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import ar.com.ctrln.persistence.model.insumo.Insumo;
import ar.com.ctrln.persistence.model.organizacion.Organizacion;
import ar.com.ctrln.persistence.model.persona.Telefono;
import ar.com.ctrln.persistence.model.servicios.TipoServicio;

@Entity
@Table(name="PROVEEDOR")
public class Proveedor extends Organizacion {

	
	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinTable(name = "TELEFONOS_PROVEEDOR", joinColumns = { @JoinColumn(name = "id_organizacion") }, inverseJoinColumns = { @JoinColumn(name = "id_telefono") })
	private Set<Telefono> telefonos;
	

	@OneToMany(mappedBy = "proveedor")
	private Collection<Insumo> insumos;
	
	//@OneToMany(mappedBy="proveedor")
	//private Collection<ServicioContratado> contratos;
	
	@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
    @JoinTable(name="PROVEEDOR_TIPOSERV",joinColumns={@JoinColumn(name="id_organizacion")},inverseJoinColumns={@JoinColumn(name="id_tipoServicio")})
    private Set<TipoServicio> tipoServicios = new HashSet<TipoServicio>();

	
	 
	 public Set<TipoServicio> getTipoServicios() {
		return tipoServicios;
	}
	public void setTipoServicios(Set<TipoServicio> tipoServicios) {
		this.tipoServicios = tipoServicios;
	}
	public Collection<Insumo> getInsumos() {
		return insumos;
	}
	public void setInsumos(Collection<Insumo> insumos) {
		this.insumos = insumos;
	}
	
	@Override
	public Set<Telefono> getTelefonos() {
		return telefonos;
	}
	@Override
	public void setTelefonos(Set<Telefono> telefonos) {
		this.telefonos = telefonos;
	}
	
	@Override
	public String toString() {
		return getRazonSocial();
	}
	
	
	
}
